/*
	Copyright (c) 2010 <copyright holders>
	This source code is licensed under The MIT License,
	see the file LICENSE for details.
	*/

#ifndef FACTION_HPP
#define FACTION_HPP

#include <vector>

#include "ForwardDecls.hpp"
#include "NetDefs.hpp"
#include "Squad.hpp"

namespace spelprog2 {
namespace sim {

class Faction {
    HIDE_EVIL_CONSTRUCTORS(Faction);

    typedef std::vector<net::UserId> Players;
    typedef std::map<Int, Squad::Pointer> Squads;
    
    Int id_;
    Int nextSquadId_;
    World & world_;
    Players players_; //I'd like to keep the possibility of cooperative play
    Squads squads_;
    Int team_;
public:
    Faction(World & world);
    ~Faction() { }

    void simUpdate(Int sequenceNbr);
	Squad::Pointer createSquad(Int numUnits, const std::string & squadType, const Int2d & pos);
    bool hasSquad(Int squadId) const { return squads_.find(squadId) != squads_.end(); }
    Squad::Pointer getSquad(Int squadId) { return squads_.find(squadId)->second; }
    Squad::ConstPointer getSquad(Int squadId) const { return squads_.find(squadId)->second; }

    void updateTeam(Int team);
};

}; //sim
}; //spelprog2

#endif //FACTION_HPP